﻿using Architecture.API.Application.TraceabilityCommand.SlaughterCommand;
using MediatR;
using Traceability.Domain.Service.BreedService;
using Traceability.Domain.Service.SlaughterServices;
using Traceability.Domain.SlaughterDomain;
using Traceability.Domain.TraceabilityDto;

namespace Architecture.API.Application.TraceabilityCommandHandler.SlaughterCommandHandler
{
    /// <summary>
    /// 屠宰信息显示命令处理器
    /// </summary>
    public class ShowSlaughterCommandHandler : IRequestHandler<ShowSlaughterCommand, List<SlaughterDto>>
    {
        /// <summary>
        /// 屠宰服务
        /// </summary>
        protected readonly ISlaughterService slaughterService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="slaughterService">屠宰服务</param>
        public ShowSlaughterCommandHandler(ISlaughterService slaughterService)
        {
            this.slaughterService = slaughterService;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<List<SlaughterDto>> Handle(ShowSlaughterCommand request, CancellationToken cancellationToken)
        {
            return await slaughterService.GetAllSlaughterList(request.shoppingId);
        }
    }
}
